#pragma once

#ifdef _cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/signal.h>
#include <time.h>
#include <signal.h> 
#include <pthread.h>
#include <sys/time.h>

#ifdef _cplusplus
}
#endif

#define UART_SERIAL_PORT1 "/dev/ttyS1"
#define UART_SERIAL_PORT2 "/dev/ttyS3"

//serial串口宏定义
#define SERIAL_PORT1 1  //串口1
#define SERIAL_PORT2 2  //串口2
#define NUM_TIMERS 4 

//串口初始化
struct rk_serial{
	int serial_fd1;
	int serial_fd2;
	char buffer_serial1[1024];
	char buffer_serial2[1024];
	ssize_t bytesRead;
	ssize_t bytesWrite;
	int Read_Flag;
	int Write_Flag;
};

extern struct rk_serial serial_info;
extern timer_t timers[NUM_TIMERS];

int init_serial();
int create_timers();
void timer_handler(int sig, siginfo_t *si, void *uc);